package com.lemon.stock.app

import androidx.datastore.preferences.core.stringPreferencesKey
import com.lemon.stock.entity.User
import com.lemon.stock.util.PerferencesDataStore

object AppPreferences {
    private val KEY_USER = stringPreferencesKey("user")

    private val datastore by lazy{
        PerferencesDataStore(StockApplication.context, StockApplication.context.packageName + ".app")
    }

    suspend fun getUser(): User? {
        return datastore.read(KEY_USER)
    }

    suspend fun setUser(user: User?) {
        datastore.write(KEY_USER, user)
    }
}